#include <head.h>

int main(int argc, char const *argv[])
{
    FILE *fp_dest = fopen(argv[1], "a+"); // 写入文件
    FOPEN_ERR(fp_dest);

    for (int i = 2; i <= argc; i++)
    {
        
        FILE *fp_src = fopen(argv[i], "r+"); // 读取文件
        FOPEN_ERR(fp_src);

        fseek(fp_dest, 0, SEEK_SET);
        fseek(fp_dest, 0, SEEK_SET);

        char buf[1024]; // 临时缓冲区

        memset(buf, 0, sizeof(buf));

        int byte = 0;
        while ((byte = fread(buf, 1, sizeof(buf), fp_src)) > 0)
        {
            fwrite(buf, 1, byte, fp_dest);
        }

        fclose(fp_src);
    }
        fclose(fp_dest);

    return 0;
}
